<?php
/**
 * @copyright meila.com
 * @author shaopu@
 * @name 生成筛选结果列表
 * @param
 *         $class = 分类ID
 *         $tag_ids =
 *         $p = 页码
 * @static
 *         PAGESIZE = 12        //12条数据一分页
 *
 *
 */
include('../../__global.php');
include(SERVER_ROOT_PATH.'/include/biz/lb_biz_filter.php');


class aj_filter_resultList extends ml_controller
{
    private $tag_ids;
    private $class_id;
    private $page;

    public function initParam()
    {
        $this->tag_ids = $this->input('tag_ids','G');
        $this->class_id = $this->input('class_id','G');
        $this->page = $this->input('page','G', 1);
    }

    public function checkParam(){
        $this->tag_ids = $this->tag_ids;
        $this->class_id = (int)$this->class_id;
        $this->page = (int)$this->page;
        $this->check_referer();
        if(empty($this->class_id) || empty($this->tag_ids)){
            $this->api_output(ML_RCODE_PARAM);
        }
    }

    public function main()
    {
        $tag_array = array_unique(explode(',',$this->tag_ids));
        $this->tag_ids = array_slice($tag_array, 0, 7);
        $oBiz = new lb_biz_filter();
        $result = $oBiz->run($this->class_id , $this->tag_ids , $this->page);
        if(empty($result['total']) && (count($tag_array)>1)) {
            $result['total'] = 0;
            $tags = ml_tool_getdata::lbJsonData('tag');

            foreach($tag_array as $value){
                $count = 0;
                $count = $oBiz->getCountByTgid($this->class_id, $value);
                $result['rows'][$value] = array('title'=>$tags[$value], 'count'=>$count);

            }
        }

        $this->api_output(ML_RCODE_SUCC , $result);
    }
}
new aj_filter_resultList();
?>